/*
 * JSON001Update.java
 *
 * Created on 31 październik 2007, 17:41
 *
 */

package kosciak.blip4j.api.json001;

import kosciak.blip4j.Update;
import kosciak.blip4j.UpdateType;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * Implementation of Update for Blip.pl API version 0.01 using JSON
 * @author Wojtek 'KosciaK' Pietrzok
 * @since 0.1
 */
class JSON001Update {
    
    /** Creates a new instance of JSON001Update */
    private JSON001Update() {
    }
    
    static Update getInstance(JSONObject obj) throws JSONException{
        Update update = null;
        String type = obj.getString("type");
        switch (UpdateType.getUpdateType(type)) {
        case Status :
            update = JSON001Status.getInstance(obj);
            break;
        case DirMsg :
            update = JSON001DirectMessage.getInstance(obj);
            break;
        }
        return update;
    }
    
}
